#include "string_algorithm_exec18.h"
char *strdup(const char *s)
{
    int length = 0;
    for (const char *p = s; ++length;)
        ;
    char *t = new char[length + 1];
    for (char *p = t; *p++ = *s++;)
        ;
    return t;
}
const char *findx(const char *s, const char *x)
{
    for (const char *p = s; *p;)
    {
        const char *q, *r;
        for (q = p, r = x; *r && *q == *r; ++q, ++r)
        {
            if (r > x && !*r)
            {
                return p;
            }
        }
    }
    return nullptr;
}
int strcmp_(const char *s1, const char *s2)
{
    for (; *s1 && *s2 && *s1 == *s2; ++s1, ++s2)
        ;
    return *s1 - *s2;
}
std::string cat_dot(const std::string &s1, const std::string &s2, const std::string &separator)
{
    return s1 + separator + s2;
}
char *cat_dot(const char *s1, const char *s2, const char *separator)
{
    int len1 = 0, len2 = 0, lens = 0;
    while (s1[len1++])
        ;
    while (s2[len2++])
        ;
    while (separator[lens++])
        ;
    char *p = new char[len1 + lens + len2 + 1];
    char *q = p;
    while (*q++ = *s1++)
        ;
    --q;
    while (*q++ = *separator++)
        ;
    --q;
    while (*q++ = *s2++)
        ;
    return p;
}